
<template>

<div>
  hello

  <el-tooltip class="item" effect="dark" content="新消息" placement="top" style="margin-right: 40px">
    <el-badge  class="item">
      <el-button @click="notice()" size="mini" type="primary" icon="el-icon-message-solid" circle></el-button>
    </el-badge>
  </el-tooltip>
</div>

</template>

<style scoped>

</style>

<script>
import axios from "axios";
import Cookies from "js-cookie";

export default {
  data (){
    return{
      is_admin:''
    }
  },
  methods:{
    notice(){
      if(this.is_admin == 'true'){
        this.$router.push({ name: 'adminnotice'});

      }
      else {
        this.$router.push({ name: 'notice'});
      }
    },
  },
  mounted() {
    this.is_admin = Cookies.get('is_admin');
    //   发送异步请求获取数据
    axios.get('http://127.0.0.1:5000/getAllusers', {
      headers: {
        'token': `Bearer ${Cookies.get('token')}`
      }
    })
        .then(response => {
          // 处理响应
          this.fullData = response.data.data;
          const start = (this.currentPage - 1) * this.pageSize;
          const end = start + this.pageSize;
          this.tableData = this.fullData.slice(start, end);
          alert(response.data.msg);
        })
        .catch(() => {
          // 处理错误
        });
  }
}
</script>
